package demo;
public class Student implements Comparable<Student>{
    private String name;
    private int age;
    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }
    @Override
    public String toString() {
        return "["+this.name+"今年"+this.age+"岁了]";
    }
    @Override
    public int compareTo(Student o){
        if(this.age>o.age)
        {
            return 1;
        }
        else if(this.age<o.age)
        {
            return -1;
        }
        else
        {
            return 0;
        }
    }
}
